﻿using System;

namespace exp2_2
{
    //定义Person类
    public class Person
    {
        string _name;

        public Person(string name)
        {
            this._name = name;
        }

        public string GetName()
        {
            return _name;
        }

    }
    //定义收作业的接口
    interface IHomeworkCollector
    {
        void CollectHomework();
    }
    //定义Teacher类
    public class Teacher : Person,IHomeworkCollector
    {
        public Teacher(string name):base(name)
        {
            
        }
        //隐式实现接口
        public void CollectHomework()
        {
            Console.WriteLine("同学们，交作业了！");
        }
    }
    //定义Student类
    public class Student : Person, IHomeworkCollector
    {
        public Student(string name):base(name)
        {
            
        }

        public void CollectHomework()
        {
            Console.WriteLine("老师，作业收集完毕！");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            /*目标
             1.已知Person类中有Teacher和Student两个子类
             2.请使用接口实现收作业功能
             */
            Teacher teacher1 = new Teacher("李红");
            Student student1 = new Student("可乐");
            Console.WriteLine("测试样例：teacher1.CollectHomework()");
            Console.WriteLine("测试样例：student1.CollectHomework()");
            Console.WriteLine("输出：");
            Console.Write("{0}:",teacher1.GetName());
            teacher1.CollectHomework();
            Console.Write("{0}：",student1.GetName());
            student1.CollectHomework();
        }
    }
}